{% set pypi_name = 'python-tripleoclient' %}
{% set upstream_version = upstream_version('14.1.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenstackClient plugin for tripleoclient
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  {{ py3('ansible-runner') }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py2pkg('tripleo-common') }}
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('cryptography') }}
BuildRequires:  {{ py3('devel') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-heatclient') }}
BuildRequires:  {{ py3('python-ironic-inspector-client') }}
BuildRequires:  {{ py3('python-ironicclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('python-openstackclient') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('passlib') }}
BuildRequires:  {{ py3('psutil') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildRequires:  {{ py3('validations-libs') }}
BuildRequires:  {{ py3('python-zaqarclient') }}
BuildArch:      noarch
%if 0%{?rdo}
BuildRequires:  hostname
%endif

%description
python-tripleoclient is a Python plugin to OpenstackClient
for TripleO.

%package -n python3-tripleoclient
Summary:        OpenstackClient plugin for tripleoclient
Requires:       {{ py3('ansible-runner') }}
Requires:       {{ py2pkg('tripleo-common') }}
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('cryptography') }}
Requires:       {{ py3('python-heatclient') }}
Requires:       {{ py3('python-ironic-inspector-client') }}
Requires:       {{ py3('python-ironicclient') }}
Requires:       {{ py3('python-mistralclient') }}
Requires:       {{ py3('python-openstackclient') }}
Requires:       {{ py3('osc-lib') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('passlib') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('psutil') }}
Requires:       {{ py3('simplejson') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('validations-libs') }}
Requires:       {{ py3('websocket-client') }}
Requires:       {{ py3('python-zaqarclient') }}

%description -n python3-tripleoclient
python-tripleoclient is a Python plugin to OpenstackClient
for TripleO.

This package contains the Python 3.x module.

%package doc
Summary:        Documentation for OpenstackClient plugin for tripleoclient
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-svg2pdfconverter') }}

%description      doc
python-tripleoclient is a Python plugin to OpenstackClient
for TripleO.
This package contains auto-generated documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-%{version}
%py_req_cleanup

%build
%{py3_build}

PYTHONPATH=. %sphinx_build -b html doc/source doc/build/html
PYTHONPATH=. %sphinx_build -b man doc/source doc/build/man
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}
# man page
install -p -D -m 644 doc/build/man/python-tripleoclient.1 %{buildroot}%{_mandir}/man1/python-tripleoclient.1


%check
%{__python3} -m stestr.cli run

%files
%doc README.rst
%license LICENSE
%{python3_sitelib}/tripleoclient
%{python3_sitelib}/*.egg-info
%{_mandir}/man1/python-tripleoclient.1.gz

%files doc
%license LICENSE
%doc doc/build/html

%changelog
